home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / WFC010.ZIP / SRC / U2A_A2U.CPP < prev   
Encoding:
C/C++ Source or Header  |  1995-12-07  |  1.4 KB  |  71 lines

  1. #include <wfc.h>
  2. #pragma hdrstop
  3.  
  4. /*
  5. ** Author: Samuel R. Blackburn
  6. ** CI$: 76300,326
  7. ** Internet: sammy@sed.csc.com
  8. **
  9. ** You can use it any way you like as long as you don't try to sell it.
  10. **
  11. ** Any attempt to sell WFC in source code form must have the permission
  12. ** of the original author. You can produce commercial executables with
  13. ** WFC but you can't sell WFC.
  14. **
  15. ** Copyright, 1995, Samuel R. Blackburn
  16. **
  17. ** $Workfile: $
  18. ** $Revision: $
  19. ** $Modtime: $
  20. */
  21.  
  22. #if defined( _DEBUG )
  23. #undef THIS_FILE
  24. static char BASED_CODE THIS_FILE[] = __FILE__;
  25. #define new DEBUG_NEW
  26. #endif
  27.  
  28. void ASCII_to_UNICODE( LPCSTR ansi_string, LPWSTR unicode_string )
  29. {
  30.    if ( ansi_string == NULL || unicode_string == NULL )
  31.    {
  32.       return;
  33.    }
  34.  
  35.    int index = 0;
  36.  
  37.    while( ansi_string[ index ] != 0x00 )
  38.    {
  39.       unicode_string[ index ] = ansi_string[ index ];
  40.       index++;
  41.    }
  42.  
  43.    unicode_string[ index ] = 0;
  44. }
  45.  
  46. void UNICODE_to_ASCII( LPCWSTR unicode_string, LPSTR ansi_string )
  47. {
  48.    if ( unicode_string == (LPCWSTR) NULL || ansi_string == (LPSTR) NULL )
  49.    {
  50.       return;
  51.    }
  52.  
  53.    int index = 0;
  54.  
  55.    while( unicode_string[ index ] != 0 )
  56.    {
  57.       if ( unicode_string[ index ] < 256 )
  58.       {
  59.          ansi_string[ index ] = (char) unicode_string[ index ];
  60.       }
  61.       else
  62.       {
  63.          ansi_string[ index ] = ' ';
  64.       }
  65.  
  66.       index++;
  67.    }
  68.  
  69.    ansi_string[ index ] = 0x00;
  70. }
  71.